{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.【判断】执行import datetime as dt 语句后，如下时间和日期定义方式错误的是：（ ）。  \n",
    "\n",
    "A.dt.datetime(2019,12,12,23,23,23)     \n",
    "B.dt.datetime(2019,0,0,23,23,23)  \n",
    "C.dt.datetime(2019,12,12,0)    \n",
    "D.dt.time(23,23,23)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：B。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2.【填空】如下代码的输出结果为：（ ）。 \n",
    "```\n",
    "import datetime as dt\n",
    "from dateutil import parser\n",
    "date= parser.parse(\"2019-1-1-1:1:1\")  \n",
    "print(date)```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：2019-01-01 01:01:01。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.【填空】如下代码的运行结果为：（ ）。\n",
    "```\n",
    "import datetime as dt\n",
    "from dateutil import parser\n",
    "date= parser.parse(\"2019-1-1-1:1:1\")\n",
    "date.strftime(\"%W\"),date.strftime(\"%B\"),date.strftime(\"%D\")```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：('00', 'January', '01/01/19')。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4.【填空】在计算时差时，计算单位可以是days、（ ）或microseconds。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：seconds。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5.【填空】如下代码的输出结果依次为：（ ）。\n",
    "```\n",
    "import datetime as dt\n",
    "import pandas as pd\n",
    "index=pd.DatetimeIndex([\"2018-1-1\",\"2018-1-2\",\"2018-1-3\",\"2018-1-4\",\"2018-1-5\"])\n",
    "data=pd.Series([1,2,3,4,5],index=index)\n",
    "print(data[\"2018-1-1\"])\n",
    "print(data-data[2])```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：\n",
    "```\n",
    "2018-01-01    1\n",
    "dtype: int64\n",
    "\n",
    "2018-01-01   -2\n",
    "2018-01-02   -1\n",
    "2018-01-03    0\n",
    "2018-01-04    1\n",
    "2018-01-05    2\n",
    "dtype: int64```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "6.【填空】如下代码的运行结果为：（ ）。\n",
    "```\n",
    "import datetime as dt\n",
    "import pandas as pd\n",
    "pd.period_range(\"2008-1-1\",periods=8,freq=\"A\")```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "答案：PeriodIndex(['2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015'], dtype='int64', freq='A-DEC')。  \n",
    "解析：代码中使用freq=\"Y\"时，系统会提示：FutureWarning: Freq \"Y\" is deprecated, use \"A\" as alternative."
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
